package com.icexxx.lathe;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@ConditionalOnClass({ RedisTemplate.class })
public class LatheWebMvcConfigurer implements WebMvcConfigurer {
    @Autowired
    private DefaultRepeatInterceptor handlerInterceptor;
    @Autowired(required = false)
    private LatheProperties latheProperties;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        handlerInterceptor.init(latheProperties);
        registry.addInterceptor(handlerInterceptor).addPathPatterns("/**");
    }

}
